import Dialog from '@vant/weapp/dialog/dialog'
Page({
  data: {
    userInfo: {},
  },
  goLogin() {
    wx.navigateTo({
      url: '/pages/login/index',
    })
  },
  onShow() {
    this.getUserInfo()
  },
  async getUserInfo() {
    const res = await wx.http({
      url: '/userInfo',
    })
    this.setData({
      userInfo: res.data.data,
    })
  },
  logout() {
    const app = getApp()
    Dialog.confirm({
      title: '退出',
      message: '确认退出?',
    })
      .then(() => {
        app.logout()
        // on confirm
      })
      .catch(() => {
        // on cancel
      })
  },
})
